<!DOCTYPE html>
<html lang="en">
<head>
    <title>滚滚向前投票助手</title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <meta http-equiv="Pragma" content="no-cache"/>
    <meta http-equiv="no-cache"/>
    <meta http-equiv="Expires" content="-1"/>
    <meta http-equiv="Cache-Control" content="no-cache"/>
    <meta http-equiv="X-UA-Compatible" content="IE=EmulateIE8"/>
    <meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no"
          name="viewport">
    <meta content="telephone=no" name="format-detection"/>
    <link rel="shortcut icon" href="/dist/img/icon.png" type="image/x-icon">
    <style>
        [v-cloak] {
            display: none;
        }

        * {
            -webkit-box-sizing: border-box;
            -moz-box-sizing: border-box;
            box-sizing: border-box;
            outline: none;
        }

        body {
            -webkit-overflow-scrolling: touch;
            　　　　overflow-scrolling: touch;
        }


        table {
            border-collapse: collapse;
            /*border-right: 1px solid #cbcbcd;*/
            /*border-bottom: 1px solid #cbcbcd;*/
            margin-left: 0px;
            margin-top: 0px;
            margin-bottom: -1px !important;
            margin-right: 0px;
        }

        .btn-blue {
            border: none;
            background: #2a8ced;
            color: #fff;
            height: 30px;
            width: 14%;
            border-radius: 3px;
        }

        .visitingBox {
            background: #fff;
            padding-bottom: 50px;
            padding-top: 45px;
        }

        .item {
            height: 44px;
            line-height: 44px;
            font-size:14px;
            position:relative;
            border-bottom:1px solid rgb(238, 238, 238);
            display:table;
            width:100%;
            overflow:hidden;
        }

        .item .xh{
            position: absolute;
            left:0;
            top:0;
            width: 40px;
            text-align: center;
            height: 44px;
            line-height: 44px;
            text-align:center;
            font-size:12px;
        }
        .item .title {
            margin-left: 40px;
            vertical-align:middle;
            display:table-cell;
            float:none;
            margin-right: 145px;
            line-height:18px;
            max-height:45px;
            overflow:hidden;
            text-overflow:ellipsis;
            display:-webkit-box;
            -webkit-box-orient:vertical;
            -webkit-line-clamp:2;
            visibility:inherit;
            margin-top: 2px;


            color: #2a8cec;

        }

        .item .time {
            color:#808080;
            position:absolute;
            width:80px;
            right:0px;
            top:0px;
            height: 44px;
            line-height: 44px;
            text-align:center;
            font-size:12px;
        }
        .item .createUser {
            color:#808080;
            position:absolute;
            width:36px;
            top:0px;
            height: 44px;
            line-height: 44px;
            font-size:12px;
            text-align: justify;
            right: 92px;
        }
        .item .createUser:after { content: " "; display: inline-block; width: 100%;}

        .btn-blue.focus, .btn-blue:focus, .btn-blue:hover {
            color: #fff;
            text-decoration: none;
        }

        .lineTwo span {
            max-height: 55px;
            line-height: 16px;
            overflow: hidden;
            text-overflow: ellipsis;
            display: -webkit-box;
            -webkit-box-orient: vertical;
            -webkit-line-clamp: 3;
            text-align: left;
            padding: 5px;

        }

        .div-td-content-more {
            position: absolute;
            height: auto;
            z-index: 999;
            line-height: 20px;
            background-color: #d3e8fd;
            padding: 8px 6px;
            border: 1px solid #e8e8ea;
            display: none;
        }

        .div-td-content-more i {
            width: 15px;
            height: 12px;
            background: url("/dist/img/more-icon.png");
            position: absolute;
            left: 50px;
            top: -12px;
        }

        .imgBox {
            margin-left: 20px;
        }

        .imgBox .title {
            padding-left: 5px;
            height: 45px;
            line-height: 45px;
            position: relative;
            font-size: 14px;
        }

        .imgBox .title i {
            position: absolute;
            left: -10px;
            top: 2px;
            color: red;
            font-size: 16px;
        }

        .imgBox img {
            width: 80px;
            height: 80px;
            margin-bottom: 20px;
        }

        .imgBox .desc {
            color: #aaa;
        }




        .btn.active {
            background: #2a8cec;
        }

        .btn {
            position: absolute;
            width: 96px;
            height: 96px;
            left: 50%;
            top: 50%;
            margin-left: -48px;
            margin-top: -48px;
            border-radius: 50%;
            background: #dfdfdf;
            color: #fff;
        }

        .btn .time {
            font-size: 20px;
            margin-top: 14px;
        }

        .btn .start {
            font-size: 16px;
        }





        .tijiaoBtn {
            position: fixed;
            bottom: 0;
            left: 0;
            width: 100%;
            height: 50px;
            line-height: 50px;
            background: #2a8cec;
            color: #fff;
            text-align: center;
            font-weight: bold;
            font-size: 16px;
            z-index: 9999999;
        }

        .noData {
            padding-top: 60px;
            font-size: 16px;
            color: #ddd;
            text-align: center;
        }

        .item .center{
            margin-right:60px;
            display:table-cell;
            vertical-align:middle;
        }
        .titleBox{
            height: 45px;
            width: 100%;
        }
        .titleBox .left{
            float:left;
        }

        body, html {
            width: 100%;
            margin: 0;
            font-family: "微软雅黑";
        }

        #allmap, #allmap2 {
            /*width: 100%;*/
            height: 300px;
            overflow: hidden;
            margin: 0;
            font-family: "微软雅黑";
        }

        [v-cloak] {
            display: none;
        }

        * {
            -webkit-box-sizing: border-box;
            -moz-box-sizing: border-box;
            box-sizing: border-box;
            font-size: 12px;
        }

        body {
            margin: 1px;
            background: #ffffff;
        }

        .boxBoy {
            background: #fff;
        }

        table {
            border-spacing: 0;
            border-collapse: collapse;
            display: table;
        }

        .weather {
            text-align: center;
            font-size: 16px;
            /*position: absolute;*/
            top: 5px;
            line-height: 30px;
            float: left;
        }

        th {
            font-weight: normal;
        }

        table.text-center, table.text-center td, table.text-center th {
            text-align: center;
            font-size: 12px;
            margin-top: -1px;
            height: 45px;

        }

        .table-bordered > thead > tr > th, .table-bordered > tbody > tr > th, .table-bordered > tfoot > tr > th, .table-bordered > thead > tr > td, .table-bordered > tbody > tr > td, .table-bordered > tfoot > tr > td {
            border: 1px solid #cbcbcd;
            height: 28px;
            position: relative;
            color: #333;
            padding: 0 4px;
        }

        table th {
            background: #d3e8fd;
        }

        .table-bordered {
            border: 1px solid #cbcbcd;
        }

        .table {
            width: 100%;
            max-width: 100%;
        }
        .fixHeader{
            top:0;
            left:0;
            width: 100%;
            position: fixed;
            z-index: 99999;
        }
        .tjResult{
            color: #2a8cec;
            position: absolute;
            width: 80px;
            right: 0px;
            top: 0px;
            height: 44px;
            line-height: 44px;
            text-align: center;
            font-size: 12px;
        }
        .bz{
            position: absolute;
            top: 13px;
            left: 50%;
            margin-left: -18px;
            font-style: inherit;
            transform: scale(0.9);
        }
        .tjResultNo{
            color: red;
            position: absolute;
            width: 80px;
            right: 0px;
            top: 13px;
            height: 44px;
            line-height: 44px;
            text-align: center;
            font-size: 12px;
        }
        .endItem{
            color:#808080;
        }
        .endItem .title{
            color:#808080;
        }
        .endItem .createUser{
            color:#808080;
        }
        .endItem .tjResult{
            color:#808080;
        }

    </style>
</head>
<body>
<section class="content" id="app" style="padding: 0px;" v-cloak>
    <table class="table table-hover text-center fixHeader">
        <thead>
        <tr>
            <th style="text-align: center;padding-left: 5px;width: 40px;">序号</th>
            <th style="text-align: center;padding-left: 5px;">投票内容</th>
            <th style="width: 60px">创建人</th>
            <th style="width: 80px">状态</th>
        </tr>
        </thead>
    </table>
    <div id="scroll" class="scrollHeight" style="margin-top: 45px;padding-bottom: 50px;">
            <table class="table visitingBox">
                <tbody>
                <tr v-for="(item,i) in list" :class="item.auditFlag==='2'||item.auditFlag==='1'||item.auditFlag==='3'?'item endItem':'item'">
                    <td>
                        <div class="center">
                            <div class="xh" @click="goDetail(item)">{{i+1}}</div>

                            <div class="createUser">{{item.createUserName}}</div>

                            <!--状态显示   auditFlag==='-5' 草稿 -->
                            <template v-if="item.auditFlag==='-5'">
                                <div class="title" @click="goLookCreate(item,userInfo.name)">{{item.title}}</div>
                                <div class="tjResult"  @click="goLookCreate(item,userInfo.name)" >未提交</div>
                            </template>

                            <!--状态显示   auditFlag==='-4' 新建 被驳回 -->
                            <template v-if="item.auditFlag==='-4'">
                                <div class="title" @click="goLookCreate(item,userInfo.name)">{{item.title}}</div>
                                <div class="tjResult"  @click="goLookCreate(item,userInfo.name)" >新建投票 <i class="bz" style="color:red;">已驳回</i></div>
                            </template>

                            <!--状态显示   auditFlag==='-3' 新建 待审核 -->
                            <template v-if="item.auditFlag==='-3'">
                                <div class="title" @click="goLookCreate(item,userInfo.name)">{{item.title}}</div>
                                <div class="tjResult"  @click="goLookCreate(item,userInfo.name)" >新建投票 <i class="bz" style="color:red;">待审核</i></div>
                            </template>

                            <!--状态显示   auditFlag==='-2' 新建 未全部上传附件 -->
                            <template v-if="item.auditFlag==='-2'">
                                <!--未上传投票人员--》点击前往上传附件-->
                                <template v-if="(item.noFjNames.indexOf(userInfo.name)>-1)">
                                    <div class="title" @click="goUpload(item,userInfo.name)">{{item.title}}</div>
                                    <div class="tjResult"  @click="goUpload(item,userInfo.name)" style="color:red;">未上传</div>
                                </template>
                                <!--所有人未上传完成&&当前登录人为创建人--》点击前往修改页面-->
                                <template v-else-if="item.createUserId==userId">
                                    <div class="title" @click="goLookCreate(item)">{{item.title}}</div>
                                    <div class="tjResult"  @click="goLookCreate(item)" style="line-height: 22px;    ">已上传:<span style="width: 20px;display: inline-block;">{{item.allFj-item.wscFj}}</span><br>未上传:<span style="width: 20px;display: inline-block;">{{item.wscFj}}</span></div>
                                </template>
                                <template v-else>
                                    <!--其余人-->
                                    <div class="title" @click="goDetail(item)">{{item.title}}</div>
                                    <div class="tjResult" @click="goDetail(item)" style="line-height: 22px;    ">已上传:<span style="width: 20px;display: inline-block;">{{item.allFj-item.wscFj}}</span><br>未上传:<span style="width: 20px;display: inline-block;">{{item.wscFj}}</span></div>
                                </template>

                            </template>

                            <!--状态显示   auditFlag==='-1' 投票中 -->
                            <template v-if="item.auditFlag==='-1'">
                                <!--所有人未上传完成&&当前登录人为创建人--》点击前往修改页面-->
                                <template v-if="item.createUserId==userId">
                                    <div class="title" @click="goDetail(item)">{{item.title}}</div>
                                    <div class="tjResult"  @click="goResult(item)" >投票中</div>
                                </template>
                                <!--其余人-->
                                <template v-else>
                                    <div class="title" @click="goDetail(item)">{{item.title}}</div>
                                    <div class="tjResult"   @click="goDetail(item)" >投票中</div>
                                </template>
                            </template>

                            <!--状态显示   auditFlag==='0' 审核中 -->
                            <template v-if="item.auditFlag==='0'">
                                <!--未结束投票-->
                                <template v-if="compareDate(item.endTime)">
                                    <div class="title" @click="goDetail(item)">{{item.title}}</div>
                                    <div class="tjResult" @click="goDetail(item)">投票中</div>
                                </template>
                                <!--已结束投票-->
                                <template v-else>
                                    <div class="title" @click="goDetail(item)">{{item.title}}</div>
                                    <div class="tjResult" @click="goResult(item)" >投票结果 <i class="bz" style="color:red;">待审核</i></div>
                                </template>
                            </template>

                            <!--状态显示   auditFlag==='2' 已驳回 -->
                            <template v-if="item.auditFlag==='2'">
                                <div class="title" @click="goDetail(item)">{{item.title}}</div>
                                <div class="tjResult"  @click="goResult(item)" >投票结果 <i class="bz">已驳回</i></div>
                            </template>

                            <!--状态显示   auditFlag==='1' 已通过 -->
                            <template v-if="item.auditFlag==='1'">
                                <div class="title" @click="goDetail(item)">{{item.title}}</div>
                                <div class="tjResult"  @click="goResult(item)">已通过</div>
                            </template>

                            <!--状态显示   auditFlag==='3' 已通过 -->
                            <template v-if="item.auditFlag==='3'">
                                <div class="title" @click="goDetail(item)">{{item.title}}</div>
                                <div class="tjResult"  @click="goResult(item)">已通过</div>
                            </template>

                        </div>
                    </td>

                </tr>
                </tbody>
            </table>
        <div class="noData" v-if="!list||list.length==0">暂无投票，新建一个试试</div>
    </div>

    <div class="tijiaoBtn" @click="goAdd" >新建投票</div>
</section>
<!--JQ-->

<script src="https://file.ggxqce.com/web/axios.min.js"></script>

<script src="/dist/js/newOaApp.js"></script>
<!--插件JS-->

<!--框架已定义 JS-->
<!--oa自定义  JS-->
<script type="text/javascript" src="/dist/plugins/vue/vue.js"></script>


<script type="text/javascript">
    function NewDate(str){
        if(!str){
            return 0;
        }
        arr=str.split(" ");
        d=arr[0].split("-");
        t=arr[1].split(":");
        var date = new Date();
        date.setUTCFullYear(d[0], d[1] - 1, d[2]);
        date.setUTCHours(t[0]-8, t[1], t[2], 0);
        return date;
    }
    var app = new Vue({
        el: '#app',
        data: {
            userInfo:{},
            userId: getUrlParamObj().userId,
            date: "",
            list: [],
            isMore: false,
            swiper:"",
            mySwiper:"",
            rightOp:[]
        },
        methods: {
            setScrollTop: function (isScrollTop) {
                var param = {
                    isScrollTop: isScrollTop
                }
                JSBridge.call(UI, 'setScrollTop', param)
            },
            initList:function (list) {
                var newList=[];
                for(var i=0;i<list.length;i++){
                    var data=list[i];
                    if(data.ctNames){
                        data.allFj=data.ctNames.split(",").length;
                    }else{
                        data.allFj=0;
                    }
                    if(data.noFjNames){
                        data.wscFj=data.noFjNames.split(",").length;
                    }else{
                        data.wscFj=0;
                    }

                    if(data.auditFlag=='-5'){
                        if(data.createUserId==this.userId||(data.type==3&&(this.userInfo.roleName=='集团销售管理'||this.userInfo.name=='曹国玉'))){
                            newList.push(data);
                        }
                    }else if(data.auditFlag=='-4'){
                        if(data.createUserId==this.userId||data.currentAuditorId==this.userId){
                            newList.push(data);
                        }
                    }
                    else if(data.auditFlag=='-3'){
                        if(data.createUserId==this.userId||(data.createAuditIds.indexOf(this.userId)>-1)){
                            newList.push(data);
                        }
                    }else{
                        newList.push(data);
                    }
                }
                return newList
            },
            isShowBtn: function (eName) {
                if (getCurrentUser().superUser || this.isHasRightOp(eName)) {
                    return true;
                } else {
                    return false;
                }
            },
            isHasRightOp: function (eName) {
                return $.inArray(eName, this.rightOp) > -1;
            },
            goLookCreate:function (item) {
                var param = {
                    screenType: '0',        //默认竖屏0, 横屏1
                    title: item.title,         //顶部标题
                    url: '/page/voteApp/create.html?userId='+this.userId+"&mainId="+item.id, //路径
                    showTitleBar: false,     //是否显示标题栏
                    enableRefresh: false,   //是否启用下拉刷新
                    backRefresh: true       //是否返回刷新
                }
                JSBridge.call(ROUTER, 'navigateTo', param)
            },

            goResult:function (item) {
                var param = {
                    screenType: '0',        //默认竖屏0, 横屏1
                    title: item.title,         //顶部标题
                    url: '/page/voteApp/result.html?mainId='+item.id+"&userId="+this.userId+"&title="+item.title, //路径
                    showTitleBar: false,     //是否显示标题栏
                    enableRefresh: false,   //是否启用下拉刷新
                    backRefresh: true       //是否返回刷新
                }
                JSBridge.call(ROUTER, 'navigateTo', param)
            },

            goDetail: function (item,name) {
                var url='/page/voteApp/detail.html?mainId='+item.id+"&userId="+this.userId
                if(name){
                    url='/page/voteApp/detail.html?mainId='+item.id+"&userId="+this.userId+"&name="+name;
                }
                var param = {
                    screenType: '0',        //默认竖屏0, 横屏1
                    title: item.title,         //顶部标题
                    url: url, //路径
                    showTitleBar: false,     //是否显示标题栏
                    enableRefresh: false,   //是否启用下拉刷新
                    backRefresh: true       //是否返回刷新
                }
                JSBridge.call(ROUTER, 'navigateTo', param)
            },
            goAdd: function () {
                var param = {
                    screenType: '0',        //默认竖屏0, 横屏1
                    title: '新建投票',         //顶部标题
                    url: '/page/voteApp/create.html?userId='+this.userId, //路径
                    showTitleBar: false,     //是否显示标题栏
                    enableRefresh: false,   //是否启用下拉刷新
                    backRefresh: true       //是否返回刷新
                }
                JSBridge.call(ROUTER, 'navigateTo', param)

            },
            goUpload:function (item,name) {
                var param = {
                    screenType: '0',        //默认竖屏0, 横屏1
                    title: '上传参投文件',         //顶部标题
                    url: '/page/voteApp/detail.html?userId='+this.userId+'&mainId='+item.id+"&name="+name+"&title="+item.title+"&scfj=true", //路径
                    showTitleBar: false,     //是否显示标题栏
                    enableRefresh: false,   //是否启用下拉刷新
                    backRefresh: true       //是否返回刷新
                }
                JSBridge.call(ROUTER, 'navigateTo', param)
            },
            formatDate: function (now) {
                return  new Date(now).Format(TimeFormat.middle);

            },
            compareDate:function(d1) {
                return ((new Date(d1)) > (new Date()));
            }


        },
        mounted: function () {
            //开启下拉刷新
            var param = {
                pullRefresh: true, //是否开启原生下拉刷新
            }
            JSBridge.call(UI, 'setPullRefresh', param)

            var that=this;
            var _this = this; //声明一个变量指向Vue实例this，保证作用域一致
            _this.date = new Date().Format("hh:mm"); //修改数据date
            JSBridge.call(UI, 'showLoading', {})
            this.timer = setInterval(function () {
                _this.date = new Date().Format("hh:mm"); //修改数据date
            }, 1000)
            axios.post('vote/getUserInfoByUserId.json', {id:_this.userId})
                .then(function (res) {
                    _this.userInfo=res.userInfo;
                    axios.post('/vote/getVoteList.json', {userId:_this.userId,companyId:_this.userInfo.companyId,roleName:_this.userInfo.roleName})
                        .then(function (res) {
                            _this.list = _this.initList(res.voteList);
                            setTimeout(function () {
                                JSBridge.call(UI, 'hideLoading')
                            },1000)
                        })
                        .catch(function (error) {
                            console.log(error);
                        });
                })
                .catch(function (error) {
                    console.log(error);
                });

            console.log(new Date())

        }
    });

</script>
<!--<script>-->
    <!--var H = window.innerHeight-->
    <!--document.getElementsByClassName("scrollHeight")[0].style.height = (H - 97) + 'px';-->
<!--</script>-->
<script>
    var isTop = true
    window.onscroll= function(){
        console.log("11")
        //为了保证兼容性，这里取两个值，哪个有值取哪一个,scrollTop就是触发滚轮事件时滚轮的高度
        var scrollTop = document.documentElement.scrollTop || document.body.scrollTop;
        if (scrollTop === 0) {
            isTop = true
            app.setScrollTop(true) //到达顶部
        } else if (scrollTop > 0 && isTop) {
            isTop = false
            app.setScrollTop(false) //非顶部
        }
    }
</script>
</body>